package com.ss.android.account.model;

import com.bytedance.common.utility.collection.e;
import com.ss.android.common.AbsApiThread;
import com.ss.android.newmedia.a.MediaItem;
import org.json.JSONException;
import org.json.JSONObject;

public class BaseUser implements MediaItem {
    public static class SpipeUserStatus {
        boolean mIsBlocked;
        boolean mIsBlocking;
        boolean mIsFollowed;
        boolean mIsFollowing;
        boolean mIsParsed;
        final long mUserId;
        protected static e sCache;

        static {
            sCache = new e();
        }

        private SpipeUserStatus(long arg2) {

            this.mUserId = arg2;
        }

        public boolean isBlocked() {
            return this.mIsBlocked;
        }

        public boolean isBlocking() {
            return this.mIsBlocking;
        }

        public boolean isFollowed() {
            return this.mIsFollowed;
        }

        public boolean isFollowing() {
            return this.mIsFollowing;
        }

        public boolean isParsed() {
            return this.mIsParsed;
        }

        public static SpipeUserStatus obtain(long arg4) {
            Object v0_1;
            Class v1 = SpipeUserStatus.class;
            synchronized (v1){
                v0_1 = SpipeUserStatus.sCache.a(Long.valueOf(arg4));
                if(v0_1 == null) {
                    v0_1 = new SpipeUserStatus(arg4);
                    SpipeUserStatus.sCache.a(Long.valueOf(arg4), v0_1);
                }
            }
            return ((SpipeUserStatus)v0_1);
        }

        public void setIsBlocked(boolean arg1) {
            this.mIsBlocked = arg1;
        }

        public void setIsBlocking(boolean arg1) {
            this.mIsBlocking = arg1;
        }

        public void setIsFollowed(boolean arg1) {
            this.mIsFollowed = arg1;
        }

        public void setIsFollowing(boolean arg1) {
            this.mIsFollowing = arg1;
        }

        public void setIsParsed(boolean arg1) {
            this.mIsParsed = arg1;
        }
    }

    public String mFailReason;
    public boolean mIsLoading;
    private final String mKey;
    public long mMediaId;
    public long mMessageUserId;
    public String mNewReason;
    public String mNewSource;
    public int mReasonType;
    public final SpipeUserStatus mStatus;
    public final long mUserId;

    public BaseUser(long arg6) {
        this.mMessageUserId = 0;
        this.mReasonType = 0;
        this.mUserId = arg6;
        String v0 = arg6 >= 0 ? String.valueOf(arg6) : "";
        this.mKey = v0;
        this.mIsLoading = false;
        this.mStatus = SpipeUserStatus.obtain(arg6);
    }

    public boolean extractFields(JSONObject arg2) {
        boolean v0;
        if(arg2 == null) {
            v0 = false;
        }
        else {
            this.extractIsFollowed(arg2);
            this.extractIsBlocking(arg2);
            this.extractIsFollowing(arg2);
            this.extractIsBlocked(arg2);
            this.extractMessageUserId(arg2);
            v0 = true;
        }

        return v0;
    }

    public void extractIsBlocked(JSONObject arg3) {
        if(arg3 != null && (arg3.has("is_blocked"))) {
            this.setIsBlocked(AbsApiThread.optBoolean(arg3, "is_blocked", false));
        }
    }

    public void extractIsBlocking(JSONObject arg3) {
        if(arg3 != null && (arg3.has("is_blocking"))) {
            this.setIsBlocking(AbsApiThread.optBoolean(arg3, "is_blocking", false));
        }
    }

    public void extractIsFollowed(JSONObject arg3) {
        if(arg3 != null && (arg3.has("is_followed"))) {
            this.setIsFollowed(AbsApiThread.optBoolean(arg3, "is_followed", false));
        }
    }

    public void extractIsFollowing(JSONObject arg3) {
        if(arg3 != null && (arg3.has("is_following"))) {
            this.setIsFollowing(AbsApiThread.optBoolean(arg3, "is_following", false));
        }
    }

    public void extractMediaId(JSONObject arg5) {
        if(arg5 != null && (arg5.has("media_id"))) {
            try {
                this.mMediaId = arg5.optLong("media_id", 0);
            }
            catch(Exception v0) {
            }
        }
    }

    public void extractMessageUserId(JSONObject arg3) {
        if(arg3 != null && (arg3.has("message_user_id"))) {
            this.mMessageUserId = arg3.optLong("message_user_id");
        }
    }

    public String getItemKey() {
        return this.mKey;
    }

    public boolean hasBlockRelation() {
        boolean v0 = (this.mStatus.isBlocked()) || (this.mStatus.isBlocking()) ? true : false;
        return v0;
    }

    public boolean isBlocked() {
        return this.mStatus.isBlocked();
    }

    public boolean isBlocking() {
        return this.mStatus.isBlocking();
    }

    public boolean isFollowed() {
        return this.mStatus.isFollowed();
    }

    public boolean isFollowing() {
        return this.mStatus.isFollowing();
    }

    public boolean isParsed() {
        return this.mStatus.isParsed();
    }

    public void setIsBlocked(boolean arg2) {
        this.mStatus.setIsBlocked(arg2);
    }

    public void setIsBlocking(boolean arg2) {
        this.mStatus.setIsBlocking(arg2);
    }

    public void setIsFollowed(boolean arg2) {
        this.mStatus.setIsFollowed(arg2);
    }

    public void setIsFollowing(boolean arg2) {
        this.mStatus.setIsFollowing(arg2);
    }

    public void setIsParsed(boolean arg2) {
        this.mStatus.setIsParsed(arg2);
    }

    public boolean skipDedup() {
        return false;
    }

    public JSONObject toJson() throws JSONException {
        JSONObject v0 = new JSONObject();
        v0.put("is_following", this.isFollowing());
        v0.put("is_followed", this.isFollowed());
        v0.put("is_blocking", this.isBlocking());
        v0.put("is_blocked", this.isBlocked());
        v0.put("message_user_id", this.mMessageUserId);
        return v0;
    }

    public void updateFields(BaseUser arg5) {
        if(arg5 != null) {
            this.setIsBlocked(arg5.isBlocked());
            this.setIsBlocking(arg5.isBlocking());
            this.setIsFollowed(arg5.isFollowed());
            this.setIsFollowing(arg5.isFollowing());
            if(arg5.mMessageUserId > 0) {
                this.mMessageUserId = arg5.mMessageUserId;
            }
        }
    }
}

